﻿#region Copyright information
// 
// Copyright © 2012-2013 Yongkee Cho. All rights reserved.
// 
// This code is a part of the SubnetworkToolkit and governed under the terms of the
// GNU Lesser General  Public License (LGPL) version 2.1 which accompanies this distribution.
// For more information on the LGPL, please visit http://bol.codeplex.com/license.
// 
// - Filename: Options.cs
// - Author: Yongkee Cho
// - Email: yongkeecho@outlook.com
// - Date Created: 2013-01-30 2:55 PM
// - Last Modified: 2013-01-30 3:21 PM
// 
#endregion
using System;
using System.Collections.Generic;
using System.Text;
using BOL.Algorithms.Optimization.EvolutionaryAlgorithms;
using CommandLine;

namespace SubnetworkToolkit.GeneticAlgorithmSearch
{
    public class Options
    {
        [Option("e", "seed", DefaultValue = 0, HelpText = "Specify a random seed.")]
        public int Seed { get; set; }

        [Option("q", "background network", HelpText = "Specify a method: Greedy or Genetic")]
        public string NetworkFile { get; set; }

        [Option("s", "statisticsfile", HelpText = "Specify an statistics file.")]
        public string StatisticsFile { get; set; }

        [Option("o", "outputFile", HelpText = "Specify the output file.")]
        public string OutputFile { get; set; }

        [Option("y", "threshold", DefaultValue = 1e-10, HelpText = "Specify a threshold.")]
        public double Threshold { get; set; }

        [Option("z", "elite", DefaultValue = 0, HelpText = "Sepecify the number of elites.")]
        public int NumberOfElites { get; set; }

        [Option("t", "top", HelpText = "Sepecify how many subnetwork will be taken.")]
        public int Top { get; set; }

        [Option("i", "min", DefaultValue = 3, HelpText = "Specify the minimum size of nodes.")]
        public int MinNodes { get; set; }

        [Option("x", "max", DefaultValue = 30, HelpText = "Specify the maximum size of nodes.")]
        public int MaxNodes { get; set; }

        [Option("p", "population", HelpText = "Specify the population size.")]
        public int PopulationSize { get; set; }

        [Option("l", "selection", DefaultValue = SelectionMethod.Rank, HelpText = "Specify a selection method. [rank:tournament:roulettewheel]")]
        public SelectionMethod SelectionMethod { get; set; }

        [Option("k", "k", DefaultValue = 100, HelpText = "Specify tournament K.")]
        public int K { get; set; }

        [Option("c", "crossover", DefaultValue = 0.5, HelpText = "Specify the crossover rate.")]
        public double CrossoverRate { get; set; }

        [Option("u", "mutation", DefaultValue = -1, HelpText = "Specify the mutation rate.")]
        public double MutationRate { get; set; }

        [Option("w", "redundancy", DefaultValue = 0, HelpText = "Specify if redundancy in the population is allowed.")]
        public int AllowRedundancy { get; set; }

        [Option("b", "parallel", DefaultValue = 0, HelpText = "Specify if parallel option is allowed or not.")]
        public int DoParallel { get; set; }

        [Option("v", "verbose", DefaultValue = 1, HelpText = "Sepecify if it prints out on screen.")]
        public int IsVerbose { get; set; }

        [Option("d", "stationary", DefaultValue = 10, HelpText = "Sepecify the sationary...")]
        public int Stationary { get; set; }

        [Option("f", "force", DefaultValue = 0, HelpText = "Sepecify ...")]
        public int IsForcing { get; set; }

        [OptionList("n", "include", DefaultValue = new string[0], Separator = ':', HelpText = "Sepecify ...")]
        public IList<string> Bypass { get; set; }

        [HelpOption(HelpText = "Dispaly this help screen.")]
        public string GetUsage()
        {
            var help = new StringBuilder();
            help.AppendLine(Type.GetType("Mono.Runtime") != null
                                ? "Usage : mono gsa.exe [OPTION]"
                                : "Usage : gsa [OPTION]");
            help.AppendLine("Options:");
            help.AppendLine("    -e           random seed");
            help.AppendLine("    -q           network file");
            help.AppendLine("    -s           statistics file");
            help.AppendLine("    -o           output file");
            help.AppendLine("    -y           threshold");
            help.AppendLine("    -t           top n to take");
            help.AppendLine("    -i           min # nodes");
            help.AppendLine("    -x           max # nodes");
            help.AppendLine("    -p           number of population");
            help.AppendLine("    -l           selection method");
            help.AppendLine("    -k           tournament k");
            help.AppendLine("    -c           crossover rate");
            help.AppendLine("    -u           mutation rate");
            help.AppendLine("    -g           number of generations");
            help.AppendLine("    -w           allow redundancy in population");
            help.AppendLine("    -b           parallel");
            help.AppendLine("    -v           verbose mode (0: false, 1: true)");
            help.AppendLine("    -d           number of stationary solutions");
            help.AppendLine("    -f           bypassing (0) or forcing (1)");
            help.AppendLine("    -n           including gene ids");
            help.AppendLine();
            return help.ToString();
        }
    }
}
